<?php
session_start();
$user = $_SESSION["id_usuario"];

function conectarse(){
	$db_host="127.0.0.1";
	$db_nombre="iusm";
	$db_user="iusm";
	$db_pass="iusm";
	$link=mysql_connect($db_host, $db_user, $db_pass) or die ("Error conectando a la base de datos.");
	mysql_select_db($db_nombre ,$link) or die("Error seleccionando la base de datos."); 
	return $link;
}

$link = conectarse();
$query = "SELECT id FROM usuarios WHERE user = '$user';";
$result = mysql_query($query,$link);
$id = mysql_fetch_row($result);
$id_user = $id[0];
mysql_close($link);

function muestraHorario($id_user){
	$link = conectarse();
	$query = "SELECT id, bloque, ramo, sala FROM horarios WHERE id_user = '$id_user';";
	$result = mysql_query($query,$link);
	if(mysql_num_rows($result)==0) {
		echo "No se han podido obtener los horarios dese SIGA.";
		return 0;  }
	
	for($i=0;$i<mysql_num_rows($result);$i++){
		$emp=mysql_fetch_row($result);
		    echo '<li>';
			echo '<a class="noeffect" href="render.php?sala='.$emp[3].'"><span class="number">'.$emp[1].'</span>';
			echo '<span class="name">'.$emp[2].'</span><span class="time">Sala: '.$emp[3].'</span><span class="arrow"></span></a>';
	        echo "</li>";}
	
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta content="index,follow" name="robots" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link href="../homescreen.gif" rel="apple-touch-icon" />
<meta content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" name="viewport" />
<link href="../css/style.css" rel="stylesheet" media="screen" type="text/css" />
<script src="../javascript/functions.js" type="text/javascript"></script>
<title>iUSM</title>
</head>

<body class="musiclist">

<div id="topbar">
	<div id="leftnav">
		<a href="../pc.html"><img alt="home" src="../images/home.png" /></a></div>
</div>
<div id="content">
<br><br />
<span class="graytitle">Mi Horario de Hoy</span>
	<ul>
    	<?php muestraHorario($id_user); ?>
	</ul>
</div>
<div id="footer">
	<a href="http://iusm.thinktel.cl">iUSM</a></div>

</body>

</html>

